package com.enterpriseDigitalPlatform.dto;

/**
 * @author 1512044514
 */
public class JsonRes<T> {
    private T data;
    private int code;
    private String msg;

    public void setCode(int code) {
        this.code = code;
    }

    public void setData(T data) {
        this.data = data;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public int getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }

    /**
     * 无数据返回 默认状态码为 200 提示信息为成功！
     */
    public JsonRes() {
        this.code = 200;
        this.msg = "success";
    }

    /**
     * 无数据返回 可以指定状态码和提示信息
     */
    public JsonRes(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    /**
     * 有数据返回 状态码为200 默认信息为成功
     */
    public JsonRes(T data) {
        this.data = data;
        this.code = 200;
        this.msg = "success";
    }

    /**
     * 有数据 并设置状态码和提示信息
     */
    public JsonRes(int code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }
}
